<!--
<template>
    <div class="scan" v-if="scanDivShow">
      <div id="bcid">
        <div class="tip"><van-loading type="spinner" color="#1989fa" vertical/>加载中...</div>
      </div>
    </div>
</template>

<script  type='text/ecmascript-6'>

  export default {
    name: "appScan",
    data(){
      return{
        scanDivShow:false,
        scan:''
      }
    },
    methods:{
      //扫码部分
      scanClick(){
        //若是true，则正在扫描，不用再扫
        if(this.scanDivShow){
          return;
        }
        this.scanDivShow=true;
        setTimeout(() => {
          //`初始化组件
          this.startRecognize();
        }, 500);
      },
      //初始化扫描控件
      startRecognize() {
       /* let that = this;
        if (!window.plus) return;
        this.scan=null;
        this.scan = new plus.barcode.Barcode('bcid',
            [plus.barcode.QR, plus.barcode.EAN8, plus.barcode.EAN13],
            {
              frameColor: "#1294cb",
              scanbarColor: "#1294cb",
            });
        this.scan.onmarked = onmarked;
        //调用开始扫描
        this.startScan();
        //调用开始扫描
        function onmarked(type, result, file) {
          console.log("file",file);
          switch (type) {
            case plus.barcode.QR:
              type = 'QR';
              break;
            case plus.barcode.EAN13:
              type = 'EAN13';
              break;
            case plus.barcode.EAN8:
              type = 'EAN8';
              break;
            default:
              type = '其它' + type;
              break;
          }
          result = result.replace(/\n/g, '');
          that.$emit("callback",result);
          that.close();
        }*/
      },
      //开始扫描
      startScan() {
        if (!window.plus) return;
        this.scan.start();
      },
      //关闭扫描
      cancelScan() {
        if (!window.plus) return;
        this.scan.cancel();
      },
      //关闭条码识别控件
      closeScan() {
        if (!window.plus) return;
        this.scan.close();
      },
      close(){
        this.scanDivShow=false;
        this.cancelScan();
        this.closeScan();
      }
    },
    beforeDestroy(){
      this.close();
    }
  }
</script>

<style scoped lang="less">
  .scan {
    height: 100%;
    #bcid {
      width: 100%;
      height: 100%;
      z-index: 2;
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom:1rem;
      text-align: center;
      color: #fff;
      background: #ccc;
    }
    .tip {
      text-align: center;
      position: absolute;
      width: 100%;
      background: #ccc;
      top: 40%;
      z-index: 1;
      left: 0%;
    }
    footer {
      position: fixed;
      bottom: 0;
      height: 2rem;
      line-height: 2rem;
      text-align: center;
    }
  }

</style>
-->
